package io.cici.cc.mybatis.lite.mapping;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
import java.util.List;

/**
 * @author huihui
 */
@Slf4j
@Setter
@Getter
public class ParameterMappings {

    private String id;
    private Class<?> type;
    private List<ParameterMapping> parameterMappingList;

    private ParameterMappings() {
    }

    @Slf4j
    @Setter
    @Getter
    public static class Builder {
        private final ParameterMappings parameterMappings = new ParameterMappings();

        public Builder(String id, Class<?> type, List<ParameterMapping> parameterMappingList) {
            this.parameterMappings.id = id;
            this.parameterMappings.type = type;
            this.parameterMappings.parameterMappingList = parameterMappingList;
        }

        public ParameterMappings build() {
            // lock down collections
            parameterMappings.parameterMappingList = Collections.unmodifiableList(parameterMappings.parameterMappingList);
            return parameterMappings;
        }
    }

}
